<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<div style="padding: 15px">
    <form class="layui-form" action="">
        <input name="deptId" type="hidden" id="treeId"/>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                    <input type="text" name="userName" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">登录名</label>
                <div class="layui-input-inline">
                    <input type="text" name="loginName" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所在部门</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" onclick="selectDeptTree()" id="treeName" readonly="true"
                           name="deptName"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-inline">
                    <input type="text" name="phonenumber" lay-verify="required|phone" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="email" name="email" lay-verify="required|email" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <select name="sex" id="sex" lay-verify="required" lay-search="">
                        <option value="1">男</option>
                        <option value="2">女</option>
                        <option value="2">不确定</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">账号状态</label>
                <div class="layui-input-inline">
                    <select name="status" id="status" lay-verify="required" lay-search="">
                        <option value="0">正常</option>
                        <option value="1">禁用</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <input name="role" type="checkbox" th:each="role:${roles}" th:value="${role.roleId}" th:title="${role.roleName}" th:disabled="${role.status == '1'}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="user">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    /*<![CDATA[*/
    var sysUrl = '/venus/system/user';
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer;

        form.on('submit(user)', function (data) {
            data.field.roleIds= selectCheckeds("role");
            save(sysUrl, 'add', data.field);
            return false;
        });
    });

    /*]]>*/
</script>
</body>
</html>